package simax.integrator.model

import java.text.SimpleDateFormat
import org.bson.types.ObjectId

class RvMessage {

    static mapWith = "mongo"

	//ObjectId id = ObjectId.get()
    Date   time = new Date()
	String line = 'KFBG'
    String command
    String header
    String msgbody
	String from
	String to

	static mapping = {
		database    "integrator-ui"
		collection  "rvlog"
	}
	
	static dateFormat = new SimpleDateFormat('yyyy-MM-dd hh:mm:ss')
	
	static List<RvMessage> createFrom(List<Map> mapList) {
		mapList.collect { m ->
			new RvMessage(line:m.line, time:m.time, subject:m.subject, command:m.command, 
				header:m.header, msgbody:m.msgbody, from:m.from, to:m.to)
		}
	}
	
	String getSubject() {
		"${line}.LH.${to}"
	}
	
	String toString() {
		out.toString()
	}
}